package com.linwen.javase.desgin_pattern.BigTalkDesignPattenJAVACode._15组合模式._1基本代码;

class Leaf extends Component{
    public Leaf(String name){
        super(name);
    }

    public void add(Component component){
        System.out.println("Cannot add to a leaf.");
    }

    public void remove(Component component){
        System.out.println("Cannot remove from a leaf.");
    }

    public void display(int depth){
        //叶节点的具体显示方法，此处是显示其名称和级别
        for(int i = 0; i<depth; i++)
            System.out.print("-");
        System.out.println(name);
    }
}